home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <intuition/intuition.h>
- #include <intuition/screens.h>
- #include <libraries/gadtools.h>
- #include <clib/intuition_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/rtracker_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/gadtools_protos.h>
- #include <pragmas/rtracker_pragmas.h>
- #include <exec/libraries.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
-
- #include "main.h"
- #include "graph.h"
-
- extern struct Library * RTrackerBase ;
- extern struct Library * GadToolsBase ;
-
- extern SPoint * ipoint, * current ;
-
- void DrawGrid(struct Window * win) {
- struct RastPort * rport ;
- ULONG offx, offy ;
- ULONG i ;
-
- offx = win->BorderLeft ;
- offy = win->BorderTop ;
- rport = win->RPort ;
- SetAPen(rport, 0) ;
- RectFill(rport, win->BorderLeft, win->BorderTop,
- win->BorderLeft+WIDTH, win->BorderTop+HEIGHT) ;
- SetAPen(rport, 2) ;
- for(i = 0; i< WIDTH; i += GRID) {
- Move(rport, i + offx, offy) ;
- Draw(rport, i + offx, HEIGHT + offy) ;
- }
- for(i = 0; i< HEIGHT; i += GRID) {
- Move(rport, offx, i + offy) ;
- Draw(rport, WIDTH + offx, i + offy) ;
- }
- SetAPen(rport, 3) ;
- RectFill(rport, computeX(win, 104)-2, computeY(win, 144)-2,
- computeX(win, 104)+2, computeY(win, 144)+2) ;
-
- }
-
- ULONG computeX(struct Window *win, ULONG x) {
- /* transform normal X to window X
- */
- x = x / GRID ;
- x = x * GRID + win->BorderLeft ;
- return(x) ;
- }
- ULONG computeY(struct Window *win, ULONG y) {
- /* transform normal Y to window Y
- */
- y = y / GRID ;
- y = y * GRID + win->BorderTop ;
- return(y) ;
- }
-
- void DrawArrow(struct Window * win) {
- /* redraw the figure
- */
- SPoint * cp ;
- struct RastPort * rport ;
-
-
- DrawGrid(win) ;
- cp = ipoint->next ;
- if (cp) {
- /* al least 1 point exists
- */
- rport = win->RPort ;
- /* move to the first point
- */
- SetAPen(rport, 1) ; // set the black color
- Move(rport, computeX(win, cp->x+PX),
- computeY(win, cp->y+PY)) ;
- /* draw the lines
- */
-
- while(cp) {
- Draw(rport, computeX(win, cp->x+PX),
- computeY(win, cp->y+PY)) ;
- if (cp == current)
- SetAPen(rport, 2) ; // change the colour for the current point
-
- RectFill(rport, computeX(win, cp->x+PX)-2, computeY(win, cp->y+PY)-2,
- computeX(win, cp->x+PX)+2, computeY(win, cp->y+PY)+2 ) ;
- cp = cp->next ;
- SetAPen(rport, 1) ;
- }
- }
-
- }
-
- void DrawPoint(struct Window * win, WORD x, WORD y) {
- /* draw a point at X,Y on the grid (with mouse coords)
- */
- struct RastPort * rport ;
-
- rport = win->RPort ;
- /* set posiotn using the grid
- */
-
- x = x - win->BorderLeft + (GRID / 2) ;
- y = y - win->BorderTop + (GRID / 2) ;
- x = x / GRID ;
- y = y / GRID ;
- x = x * GRID + win->BorderLeft ;
- y = y * GRID + win->BorderTop ;
- SetAPen(rport, 1) ;
- RectFill(rport, x-2, y-2, x+2, y+2) ;
- }
-